Skip to main content

Integration Examples

The Content API covers AI-driven text generation and transformation tasks. You can use it to:

  • Text Generation – Generate new content from a prompt (e.g., product descriptions, blog content).
  • Summarization – Summarize longer text into key points or a shorter summary.
  • Translation – Translate text from one language to another.
  • Reformatting – Convert text from one format to another (e.g., turn a raw list of facts into a formatted paragraph).

Laravel (PHP) Example

Generating marketing copy from a prompt.

$data = [
'model' => 'gpt-4o',
'prompt' => 'Introducing our new smart thermostat. Highlight its energy-saving features and ease of use.',
'max_length' => 200,
'tone' => 'engaging'
];

$response = Http::withHeaders([
'Authorization' => 'X-API-Key YOUR_API_KEY',
])->post('https://api.outter.ai/v2/ai/content/generate', $data);

if ($response->ok()) {
$resultText = $response->json('content');
// Use $resultText as the generated marketing copy
}


For transformations like summarization or translation, you might call a different endpoint or include an "operation" field. For example, to summarize text, you could send the text and specify the operation, and Outter would return a summary in the "result" field.

Node.js Example

Summarizing a block of text using fetch.

const payload = {
model: "gpt-4o",
action: "summarize",
text: "Outter is an AI Integration platform that allows organizations to incorporate advanced AI into their apps...",
target_length: "short"
};

fetch("https://api.outter.ai/v2/ai/content/transform", {
method: "POST",
headers: {
"Authorization": "X-API-Key YOUR_API_KEY",
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
console.log("Summary:", data.transformed_text); // Ensure "transformed_text" is used consistently
});



In this example, we use a generic /transform endpoint with an "action" parameter. The response typically contains the transformed or generated text accessed as data.result.

.NET (C#) Example

Translating text from English to Spanish.

var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "X-API-Key YOUR_API_KEY");

var requestObj = new {
model = "mistral-7b-instruct-v0.3",
action = "translate",
text = "Hello, how are you?",
source_language = "en",
target_language = "es"
};

string json = JsonSerializer.Serialize(requestObj);
var content = new StringContent(json, Encoding.UTF8, "application/json");

var response = await client.PostAsync("https://api.outter.ai/v2/ai/content/transform", content);
string responseJson = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode) {
var translatedResult = JsonSerializer.Deserialize<Dictionary<string, string>>(responseJson);
Console.WriteLine("Translation: " + translatedResult["translated_text"]);
}



This example sends a text for translation. The API is instructed to translate (action: "translate") into Spanish ("target_language": "es"). The Outter API would return the translated text in the response JSON (e.g., "result": "Hola, ¿cómo estás?").